package nz.ac.massey.whatiscomputerscience.core.model;

/**
 * A polygon which can have vertices added and removed.
 * 
 * @author Nathan C Jones
 */
public interface MutablePolygon extends Polygon {

	// TODO what if adding or removing a vertex violates the polygon rules?

	// TODO polygon change observer?
	// I would say that when building these things (graphics apps) some design patterns come with too much OO overhead
	// But maybe that is not true, it might be that the graphics card - in the 3D version is the only real weak link
	// At the same time I am currently including many OO patterns with the intention of removing them later when the app is stable

	/**
	 * Add a new vertex to the polygon after the last vertex.
	 * @param coordinate the coordinate to be added.
	 */
	void addVertex(Coordinate coordinate);

	/**
	 * Add a new vertex to the polygon at the given position.
	 * @param coordinate the coordinate to be added.
	 * @param index the index of the coordinate to be added.
	 * @throws IndexOutOfBoundsException if the index is greater than the number of vertices already in the polygon.
	 */
	void addVertex(Coordinate coordinate, int index)
			throws IndexOutOfBoundsException;

	/**
	 * Remove a given coordinate from the polygon.
	 * @param coordinate the coordinate to remove.
	 */
	void removeVertex(Coordinate coordinate);

	/**
	 * Remove a coordinate from the polygon at the given index.
	 * @param index the index of the coordinate to remove.
	 * @throws IndexOutOfBoundsException if the index is greater than or equal to the number of vertices in the polygon.
	 */
	void removeVertex(int index) throws IndexOutOfBoundsException;
}
